// Standard text atlas

#if defined(VERTEX) ///////////////////////////////////////////////////

layout(location=0) in vec3 aPosition;
layout(location=2) in vec2 aTexCoord;

out vec2 vTexCoord;

void main() {

	vTexCoord = aTexCoord;
	gl_Position = vec4(aPosition.xyz, 1);
	
}

#elif defined(FRAGMENT) ///////////////////////////////////////////////

layout(location = 0) out vec4 textColor;

uniform sampler2D glyphTexture;
uniform vec4 glyphRect;

in vec2 vTexCoord;

void main(){

	textColor = vec4(0.0f, 0.0f, 0.0f, 0.0f);
	if(vTexCoord.x >= glyphRect.x && vTexCoord.x < glyphRect.x + glyphRect.z && 1.0f - vTexCoord.y >= glyphRect.y && 1.0f - vTexCoord.y < glyphRect.y + glyphRect.w) {

		textColor += vec4(texture(glyphTexture, vec2((vTexCoord.x - glyphRect.x) / glyphRect.z, (1.0f - vTexCoord.y - glyphRect.y) / glyphRect.w)).rrrr);

	}

}

#endif

